home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / sdoc210 / sdsample.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-07  |  2.4 KB  |  75 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Subdoc sample project"
  4.    ClientHeight    =   5820
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1770
  7.    ClientWidth     =   7365
  8.    Height          =   6510
  9.    KeyPreview      =   -1  'True
  10.    Left            =   1035
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5820
  13.    ScaleWidth      =   7365
  14.    Top             =   1140
  15.    Width           =   7485
  16.    Begin Menu MStart 
  17.       Caption         =   "&Tile"
  18.    End
  19.    Begin Menu MFinish 
  20.       Caption         =   "&Finish"
  21.    End
  22. DefInt A-Z
  23. ''  This form doesn't do anything much - just a sample
  24. ''  of code for subdoc to show off with.
  25. ''  *** However try remming out the lines in MStart_Click
  26. ''      that take the loss of frame borders into account
  27. ''      and see what happens.
  28. Dim T() As TILE                    ' will contain tiles
  29. Sub MFinish_Click ()
  30.     End
  31. End Sub
  32. Sub MStart_Click ()
  33. ''  Start the sample application:-
  34. ''      ask for name, create tiles, compute form
  35. ''      dimensions then lay out tiles.
  36. ''  *** Interesting code modification in this procedure ***
  37. n$ = InputBox$("Please input a name", "", "Geoffrey")
  38. nc = Len(n$)
  39. fw = form1.Width        ' INCORRECT !!!!
  40. fh = form1.Height
  41. '   divide form EXACTLY into NC squares each way
  42. fw = form1.Width - lostframewidthintwips()
  43. fh = form1.Height - lostframeheightintwips(True)
  44. '   rem the preceeding two lines out and see what happens
  45. intvlx = fw / nc         ' intervals
  46. intvly = fh / nc
  47. form1.FontSize = Tilefontsize
  48. ReDim T(1 To nc, 1 To nc) As TILE
  49. For r = 1 To nc
  50.     For c = 1 To nc
  51.         T(r, c).top = (r - 1) * intvly
  52.         T(r, c).left = (c - 1) * intvlx
  53.         T(r, c).bottom = (r) * intvly
  54.         T(r, c).right = (c) * intvlx
  55.         T(r, c).letter = Mid$(n$, 1 + (r + c - 2) Mod nc, 1)
  56.         T(r, c).clr = QBColor(1 + ((r + c) Mod 15))
  57.         Call showtile(r, c)
  58.     Next c
  59. Next r
  60. End Sub
  61. Sub showtile (r, c)
  62. ''  Show the tile in the gloabl array T()
  63. ''  R and C are row and column indeces
  64. form1.DrawWidth = 1
  65. Dim ti As TILE
  66. ti = T(r, c)    ' current tile working var
  67. Line (ti.left, ti.top)-(ti.right, ti.bottom), ti.clr, BF
  68. Line (ti.left, ti.top)-(ti.right, ti.bottom), QBColor(0), B
  69. lw = form1.TextWidth(ti.letter)
  70. lh = form1.TextHeight(ti.letter)
  71. form1.CurrentX = (ti.left + ti.right - lw) / 2
  72. form1.CurrentY = (ti.top + ti.bottom - lh) / 2
  73. form1.Print ti.letter;
  74. End Sub
  75.